package com.takeoff.bluewhale.config;

import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;

@SpringBootConfiguration
public class SwaggerConfig {

    @Bean
	public GroupedOpenApi usersGroup(@Value("${api.version}") String appVersion) {
		return GroupedOpenApi.builder().group("all")
				.addOperationCustomizer((operation, handlerMethod) -> {
					operation.addSecurityItem(new SecurityRequirement().addList("basicScheme"));
					return operation;
				})
				.addOpenApiCustomizer(openApi -> openApi.info(new Info().title("ALL API").version(appVersion)))
				.packagesToScan("com.takeoff.bluewhale.controller")
				.build();
	}
}
